﻿///----------------------------------------------------------------
/// Copyright (C) 2008-2010 yyssoft
/// 版权所有。
///
/// 文件名：LJT_YXPMDAL.cs
/// 文件功能描述：LJT_YXPM数据访问类
///
///
/// 创建标识：yyssoft 2014/5/19
///
/// 修改标识：
/// 修改描述：
///
/// 修改标识：
/// 修改描述：
///---------------------------------------------------------------
using System;
using System.Data;
using System.Text;
using System.Collections.Generic;
using XMK.Tadong.Model;
using XMK.Framework.DataAccess;

namespace XMK.Tadong.DAL
{
    /// <summary>
    /// LJT_YXPM的数据访问类
    /// </summary>
    public class LJT_YXPMDAL
    {

        #region  构造函数

        protected DbProvider dbProvider;
        public LJT_YXPMDAL(DbProvider dbProvider)
        {
             this.dbProvider = dbProvider;
        }
       
        #endregion  构造函数

        #region  成员方法

        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">实体对象</param>
        /// <returns>成功返回主标识ID,失败返回"0"</returns>
        public string AddBySql(LJT_YXPMInfo model)
        {
//            StringBuilder sbSql = new StringBuilder(BEGINWITHOUTTRANSACTION);
//            sbSql.Append(@" INSERT INTO LJT_YXPM 
//					([ID],[JH],[DBSD1],[DBSD],[YXMC]) 
//					VALUES(@ID,@JH,@DBSD1,@DBSD,@YXMC)");
//            sbSql.Append(ENDWITHOUTTRANSACTION);

//            OracleParameter[] parameters = {
//                    new OracleParameter(":"+LJT_YXPMInfo.ID_FIELD, OracleType.Number,4),
//                    new OracleParameter(":"+LJT_YXPMInfo.JH_FIELD, OracleType.VarChar,50),
//                    new OracleParameter(":"+LJT_YXPMInfo.DBSD1_FIELD, OracleType.Number,4),
//                    new OracleParameter(":"+LJT_YXPMInfo.DBSD_FIELD, OracleType.Number,4),
//                    new OracleParameter(":"+LJT_YXPMInfo.YXMC_FIELD, OracleType.VarChar,50)};
//            parameters[0].Value = model.ID;
//            parameters[1].Value = model.JH;
//            parameters[2].Value = model.DBSD1 == int.MinValue ? DBNull.Value : (object)model.DBSD1;
//            parameters[3].Value = model.DBSD == int.MinValue ? DBNull.Value : (object)model.DBSD;
//            parameters[4].Value = model.YXMC;

//            return SqlHelper.ExecuteScalar(SqlHelper.LocalTransactionConnectionString, CommandType.Text, sbSql.ToString(), parameters).ToString();
            return "";
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">实体对象</param>
        /// <returns>成功返回"1",失败返回"0"</returns>
        public string UpdateBySql(LJT_YXPMInfo model)
        {
//            StringBuilder sbSql = new StringBuilder(BEGINWITHOUTTRANSACTION);
//            sbSql.Append(@" UPDATE LJT_YXPM 
//					SET [JH] = @JH,[DBSD1] = @DBSD1,[DBSD] = @DBSD,[YXMC] = @YXMC 
//					WHERE ID=:ID ");
//            sbSql.Append(ENDWITHOUTTRANSACTION);

//            OracleParameter[] parameters = {
//                    new OracleParameter(":"+LJT_YXPMInfo.ID_FIELD, OracleType.Number,4),
//                    new OracleParameter(":"+LJT_YXPMInfo.JH_FIELD, OracleType.VarChar,50),
//                    new OracleParameter(":"+LJT_YXPMInfo.DBSD1_FIELD, OracleType.Number,4),
//                    new OracleParameter(":"+LJT_YXPMInfo.DBSD_FIELD, OracleType.Number,4),
//                    new OracleParameter(":"+LJT_YXPMInfo.YXMC_FIELD, OracleType.VarChar,50)};
//            parameters[0].Value = model.ID;
//            parameters[1].Value = model.JH;
//            parameters[2].Value = model.DBSD1 == int.MinValue ? DBNull.Value : (object)model.DBSD1;
//            parameters[3].Value = model.DBSD == int.MinValue ? DBNull.Value : (object)model.DBSD;
//            parameters[4].Value = model.YXMC;

//            return SqlHelper.ExecuteScalar(SqlHelper.LocalTransactionConnectionString, CommandType.Text, sbSql.ToString(), parameters).ToString();
            return "";
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        /// <param name="model">实体对象</param>
        /// <returns>成功返回"1",失败返回"0"</returns>
        public string DeleteBySql(int ID)
        {
//            StringBuilder sbSql = new StringBuilder(BEGINWITHOUTTRANSACTION);
//            sbSql.Append(@" DELETE LJT_YXPM 
//					WHERE ID=:ID ");
//            sbSql.Append(ENDWITHOUTTRANSACTION);

//            OracleParameter[] parameters = {
//                    new OracleParameter(":ID", OracleType.Number,4)};
//            parameters[0].Value = ID;

//            return SqlHelper.ExecuteScalar(SqlHelper.LocalTransactionConnectionString, CommandType.Text, sbSql.ToString(), parameters).ToString();
            return "";
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DataTable GetModelBySql(int ID)
        {
            StringBuilder sbSql = new StringBuilder();
            sbSql.Append(@"SELECT ID,JH,DBSD1,DBSD,YXMC 
					FROM LJT_YXPM 
					WHERE ID=" + ID + " ");
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, sbSql.ToString());

            cmd.DbCmdInfo.CommandType = CommandType.Text;
            DataTable ds = DbHelper.ExecFullDataTable(cmd.DbProvider, cmd.DbCmdInfo);
            if (ds != null)
            {
                return ds.Copy();
            }
            return null;

           
        }


        /// <summary>
        /// 得到对象实体
        /// </summary>
        public DataTable GetModelListBySql()
        {
            StringBuilder sbSql = new StringBuilder();
            sbSql.Append(@"SELECT ID,JH,DBSD1,DBSD,YXMC FROM LJT_YXPM ");
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, sbSql.ToString());

            cmd.DbCmdInfo.CommandType = CommandType.Text;
            DataTable ds = DbHelper.ExecFullDataTable(cmd.DbProvider, cmd.DbCmdInfo);
            if (ds != null)
            {
                return ds.Copy();
            }
            return null;


        }

        //通过筛选条件获取数据
        public DataSet GetDataByWhere(string strWhere)
        {
            StringBuilder sbSql = new StringBuilder();
            sbSql.Append(@"SELECT ID,JH,DBSD1,DBSD,YXMC FROM LJT_YXPM where 1=1 " + strWhere);
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, sbSql.ToString());

            cmd.DbCmdInfo.CommandType = CommandType.Text;
            DataSet ds = DbHelper.ExecFullDataSet(cmd.DbProvider, cmd.DbCmdInfo);
            
            return ds;
        }

        //通过筛选条件获取数据
        public DataSet GetDistinctYsDataByWhere(string strWhere)
        {
            StringBuilder sbSql = new StringBuilder();
            sbSql.Append(@"select distinct(ys)  from ljt_YXPM where 1=1 " + strWhere);
            DbCmdHelper cmd = new DbCmdHelper(dbProvider, sbSql.ToString());

            cmd.DbCmdInfo.CommandType = CommandType.Text;
            DataSet ds = DbHelper.ExecFullDataSet(cmd.DbProvider, cmd.DbCmdInfo);

            return ds;
        }
        
        #endregion  成员方法

    }
}

